package uk.co.richardwkirk.funnels.controllers;

import uk.co.richardwkirk.funnels.FunnelSettings;
import uk.co.richardwkirk.funnels.model.FunnelSystem;
import uk.co.richardwkirk.funnels.model.Runner;

public class FunnelController extends BaseController {

	FunnelSystem funnels = null;
	FunnelSettings settings = null;
	
	long funnelStepInterval = 0;
	
	public FunnelController(FunnelSystem funnels_, FunnelSettings settings_)
	{
		funnels = funnels_;
		settings = settings_;
	}
	
	void processActions() {
		// Let a runner out of the funnel system
		if (settings.isExitTime(currentTime))
		{
			Runner runner = funnels.exit();
			if (runner != null) {
				funnels.addTimeInQueue(currentTime - runner.getFinishTime());
			}
		}
		
		// Move along all of the runners
		if (settings.isFunnelShiftTime(currentTime))
		{
			funnels.shift();
		}
		
	}

}
